package com.soft.javase.day04.computer;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/21
 */
public class Computer {
    private IStorage storage;

    public void setStorage(IStorage storage) {
        this.storage = storage;
    }

    public void readData() {
        if (storage != null) {
            storage.read();
        } else {
            System.out.println("没有插入移动存储设备");
        }
    }

    public void writeData() {
        if (storage != null) {
            storage.write();
        } else {
            System.out.println("没有插入移动存储设备");
        }
    }

    public void playMusicOnMP3() {
        if (storage instanceof MP3) {
            ((MP3)storage).playMusic();
        } else {
            System.out.println("当前设备不支持播放音乐");
        }
    }
}
